﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GUILibrary;

namespace MapLibrary.Players.Skills
{
    public class SkillData
    {
        /// <summary>
        /// The amount of each protein that has been invested
        /// into the skill.
        /// </summary>
        public List<IntWrapper> ProteinAmounts
        {
            get;
            set;
        }

        /// <summary>
        /// The amount of each protein you need to level.
        /// </summary>
        public List<IntWrapper> ProteinToLevel
        {
            get;
            set;
        }

        /// <summary>
        /// Current level of the skill.
        /// </summary>
        public IntWrapper CurrentLevel
        {
            get;
            set;
        }

        public void CheckAndExecuteLevelUp()
        {
            bool hasLevelUp = true;

            for (int i = 0; i < 3; i++)
            {
                if (ProteinAmounts[i].Value != ProteinToLevel[i].Value)
                    hasLevelUp = false;
            }

            if (hasLevelUp)
            {
                CurrentLevel.Value += 1;

                for (int i = 0; i < 3; i++)
                {
                    ProteinAmounts[i].Value = 0;
                }
            }
        }

        /// <summary>
        /// Returns how close the provided protein is
        /// to max, represented as a percentage.
        /// </summary>
        /// <param name="proteinIndex"></param>
        /// <returns></returns>
        public float PercentComplete(int proteinIndex)
        {
            return ((float)ProteinAmounts[proteinIndex].Value) / ProteinToLevel[proteinIndex].Value;
        }
    }
}
